// @ts-nocheck
import './jquery-3.6.0.min.js'
// import data from '../../out/back-end/back-end_Top20.json';
let list=[];
$.getJSON('../../out/front end/front end_Top20.json', function(data){
    data.forEach((item)=>{
        list.push([`${item.keyword}`,item.weight*10000])
    })
    var mark = 0;
    var wordCloud = new B2wordcloud(document.getElementById("chart"), {
        // renderer: 'div',
        list,
        tooltip: {
            formatter: function (item) {
                return '<div>' + item[0] + '</div>' + '<div>' + item[1] + '</div>'
            }
        },
        shadowColor: 'rgba(0,0,0,0.9)',
        shadowOffsetX: 2,
        shadowOffsetY: 2,
        // maxFontSize:30,
        minFontSize:40,
        shadowBlur: 5,
        color: [
            ["#00bcbe", "rgba(205, 224, 115, 1)", 1],
            ['#00fbf2', '#001e80', 1],
            ['#b0e8ff','#0278fe'],
            '#f00',
            '#ff0'
        ],
        hover: function (item) {
            console.log(item)
        },
        // color: function () { return [["rgba(0, 188, 190, 1)", "rgba(176, 239, 173, 1)", 0]] },
        click: function (a, b, c, index) {
            wordCloud.dispatchAction({
                type: mark === index ? 'downplay' : 'highlight',
                dataIndex: index,
                keepAlive: true
            })
            if (mark != index) {
                mark = index
            } else {
                mark = -1
            }
        }
    })


    window.addEventListener('resize', function () {
        wordCloud.resize()
    })
})



